﻿using System.Collections.Generic;
using GalaSoft.MvvmLight;
using ValidationSample.Validations;

namespace ValidationSample
{
    public class ViewModelBaseEx : ViewModelBase
    {
        public ViewModelBaseEx()
        {
            Validators = new List<Validator>();
        }

        protected List<Validator> Validators { get; private set; }

        protected bool ValidateAll()
        {
            bool hasErrors = false;
            Validators.ForEach(i => hasErrors |= !i.Validate());
            return !hasErrors;
        }
    }
}
